/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package proyectoexcel;

/**
 *
 * @author samara
 */

import java.sql.DriverManager;
import java.sql.Connection;
import java.sql.SQLException;

public class Conexion {
    
  public static Connection crearConexion(ParamConexion paramConexion) {

  try {
    Class.forName("org.postgresql.Driver");
  } catch (ClassNotFoundException cnfe) {
    System.out.println("Couldn't find the driver!");
    cnfe.printStackTrace();
    System.exit(1);
  }


  Connection c = null;

  try {
    c = DriverManager.getConnection("jdbc:postgresql://localhost:5432/"+paramConexion.DatabaseName,
                                    paramConexion.User, paramConexion.Password);
  } catch (SQLException se) {
    System.out.println("Couldn't connect: print out a stack trace and exit.");
    se.printStackTrace();
    System.exit(1);
  }
  return c;
  }
}